package razor.blade;

import javafx.beans.binding.*;
import javafx.scene.*;
import javafx.beans.property.*;
import javafx.beans.value.*;
import javafx.scene.image.*;
import tee.binding.*;
public class TowUpDown {
    private Numeric x;
    private Numeric y;
    private Numeric width;
    private Group root;
    private TowUpDown me;
    public Node node() {
        return root;
    }
    public TowUpDown x(double it) {
	x.value(it);
	return this;
    }
    public TowUpDown x(int it) {
	x.value(it);
	return this;
    }
    public Numeric x() {
	return x;
    }
    public TowUpDown x(It<Double> it) {
	x.bind(it);
	return this;
    }
    public TowUpDown y(double it) {
	y.value(it);
	return this;
    }
    public TowUpDown y(int it) {
	y.value(it);
	return this;
    }
    public Numeric y() {
	return y;
    }
    public TowUpDown y(It<Double> it) {
	y.bind(it);
	return this;
    }
    
    public TowUpDown width(double it) {
	width.value(it);
	return this;
    }
    public TowUpDown width(int it) {
	width.value(it);
	return this;
    }
    public Numeric width() {
	return width;
    }
    public TowUpDown width(It<Double> it) {
	width.bind(it);
	return this;
    }
    
    public TowUpDown() {
        me=this;
        x = new Numeric().value(0);
        y = new Numeric().value(0);
        width = new Numeric().value(100);
        root = new Group();
        root.getChildren().add(new ScrapeHorizontal()
                .x(x)
                .y(y)
                .width(width)
                .node());
        ImageView view = new ImageView();
        view.setImage(new Image(this.getClass().getResourceAsStream("steelHorizontal.png")));
        //view.yProperty().bind(y.subtract(8));
        //view.xProperty().bind(width.divide(2).subtract(46/2).add(x));
        root.getChildren().add(view);
	//System.out.println("start updown");
	//final DoubleBinding db=me.y.subtract(8);
	/*db.addListener(new ChangeListener<Number>() {
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                //y(newValue.doubleValue());
		System.out.println("changed - ");
            }
        });*/
	//System.out.println(me.y.subtract(8).get());
	//System.out.println(db.get());
	//y.set(100);
        /*root.getChildren().add(new Tow()
                //.height(18)
                //.width(46)
                .content(view)
                //.y(db)//me.y.subtract(8))
                //.x(width.divide(2).subtract(46/2).add(x))
                .cursor(Cursor.V_RESIZE)
                .node());*/
	root.getChildren().add(new Tow()
                .content(view)
                .x(width.divide(2).minus(47/2).plus(x).read())
                .y(y.minus(8))
                .cursor(Cursor.V_RESIZE)
                .node());
	//System.out.println("end updown");
    }
}
